<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
    <div id="app">
        <!-- <p>{{count}}</p>
        <p>{{aplus}}</p> -->
        <p>{{a.b}}</p>
        <button @click="a.b=100">change</button>
    </div>
    <script>

        const vm = new Vue({
            el:"#app",
            data () {
                return {
                    msg: 10,
                    b: 20,
                    a:{
                        b: 10
                    }
                }
            },
            beforeCreate () {
                console.log('beforeCreatet执行')  
            },
            created () {
                console.log('created执行')  
            },
            beforeMount () {
                console.log('beforeMount执行') 
            },
            mounted () {
              console.log('mounted执行')  
            },
            computed: {
                count () {
                    console.log('computed执行')
                    return this.msg + this.b
                },
                aplus: {
                    get(){
                        return this.msg
                    },
                    setv (v) {
                        return this.msg -v
                    }
                }
            },
            watch: {
                // msg (newval, oldval) {
                //     console.log('watch触发')
                //     console.log(newval, oldval)
                // }
                a: {
                    handler (nval, oval) {
                        console.log( 'watch执行', nval, oval);
                    },
                    immediate: true,  // 监听器立即执行
                    deep: true        // 深度监听
                }
            }
        })

        console.log(vm);
    </script>
</body>
</html>